package QQTest;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class Exchange extends JFrame implements ActionListener{
	JLabel jl1,jl2;
	JTextField jtf1,jtf2;
	JButton jt;
	public Exchange() {
		jl1=new JLabel("摄氏温度");
		jl2=new JLabel("华氏温度");
		jtf1=new JTextField(15);
		jtf2=new JTextField(15);
		jt=new JButton("转化");
		this.setLayout(new FlowLayout());
		this.add(jl1);
		this.add(jtf1);
		this.add(jl2);
		this.add(jtf2);
		this.add(jt);
		this.setLocation(300, 200);
		this.setSize(500,100);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		this.setTitle("温度转换");
		jt.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
	double c,f;
	String str1=jtf1.getText();
	c=Double.parseDouble(str1);
	f=c*9.0/5+32;
	jtf2.setText(Double.toString(f));
}


	public static void main(String[] args) {
		Exchange exchange = new Exchange();

	}
}
